<template>
	<view>

		<view class="uvempty" v-if="mid== undefined">
			<uv-empty mode="page" text="请先去登录"></uv-empty>
		</view>

		<view class="" v-else>
			<view class="uvlistbox">
				<uv-list>
					<uv-list-item v-for="item in signList" :key="item.id" border>
						<view class="uvlistitem">
							<view class="uvlistitem-img">
								<view>
									<uv-image :src="item.avatar" width="80rpx" height="80rpx" radius="10rpx"></uv-image>
								</view>
							</view>
							<view class="uvlistitem-user">
								<view class="user-name">{{item.nickname}}</view>
								<view class="user-text">{{item.checkin_note}}</view>
								<uv-album :urls="item.checkin_image" rowCount="3"></uv-album>
								<view class="user-time">{{item.checkin_datetime}}</view>
							</view>
						</view>
					</uv-list-item>
				</uv-list>
			</view>

			<view class="fixed-bottom">
				<uv-button text="去打卡签到" size="large" type="success" color="rgb(10, 185, 156)" @click="goTo(`/pages/index/sign?mid=${mid}`)"></uv-button>
			</view>
			<view class="uvloadmorebox" v-if="signList.length!=0">
				<uv-load-more :status="status" marginTop="60rpx" line :loadingText="loadingText" :loadmoreText="loadmoreText" :nomoreText="nomoreText" />
			</view>

			<view class="" v-if="signList.length===0">
				<uv-empty mode="list"></uv-empty>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				mid: '',
				page: 1,
				pageSize: 10,
				lastPage: 0, //总页数
				current_page: 0, //当前页码
				isTouchGround: false,
				signList: [],
				status: 'loadmore',
				loadingText: '努力加载中',
				loadmoreText: '轻轻上拉',
				nomoreText: '实在没有了',
				list: [{
						id: 11,
						snm_users_id: 990,
						avatar: "https://open.web.jinrijiesuan.cn/assets/img/avatar.png",
						checkin_datetime: "2025-07-02 16:44",
						checkin_image: ["https://open.web.jinrijiesuan.cn/uploads/20250630/dfa5aa7190c04df10a66ab29baec23ad.jpg"],
						checkin_note: "哈哈哈哈",
						nickname: "Review...",
						snm_users_id: 990
					},
					{
						id: 12,
						snm_users_id: 990,
						avatar: "https://open.web.jinrijiesuan.cn/assets/img/avatar.png",
						checkin_datetime: "2025-07-02 16:44",
						checkin_image: ["https://open.web.jinrijiesuan.cn/uploads/20250630/dfa5aa7190c04df10a66ab29baec23ad.jpg"],
						checkin_note: "6666",
						nickname: "Review...",
						snm_users_id: 990
					}
				]
			}
		},

		onLoad(options) {
			console.log(options);
			this.getMid(options)
			this.getSignDataList()
		},

		onShow() {
			// this.getSignDataList()
		},

		onReachBottom() {
			console.log(123);
			let { lastPage, current_page } = this
			if (lastPage === current_page) {
				this.status = 'nomore'
				uni.showToast({
					icon: 'none',
					title: '已经到底啦~'
				})
				console.log('全等啦111')
			} else {
				console.log('哈哈哈')
				this.page++
				this.status = 'loading'
				this.getSignDataList()
			}
		},

		methods: {

			// 获取mid
			getMid(options) {
				this.mid = options.mid
				console.log(this.mid == '', 444);
			},

			// 获取打卡数据
			getSignDataList() {
				let that = this
				let { page, pageSize, mid } = that
				uni.request({
					url: `https://open.web.jinrijiesuan.cn/snm/index?mid=${mid}&page=${page}&page_size=${pageSize}`,
					success(res) {
						that.current_page = res.data.data.current_page
						that.lastPage = res.data.data.last_page

						// let lp = res.data.data.last_page
						// let cp = res.data.data.current_page
						that.signList = that.signList.concat(res.data.data.data)
						that.status = 'nomore'
					}
				})
			},

			// 使用 uni.navigateTo 跳转到 album 页面
			goTo(page) {
				uni.navigateTo({
					url: page,
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	.uvlistbox {
		// padding-bottom: 200rpx;
	}

	.uvempty {
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.uvlistitem {
		padding: 40rpx;
		box-sizing: border-box;
		display: flex;
		// background-color: #55ffff;

		.uvlistitem-img {
			margin-right: 30rpx;
			display: flex;
			flex-direction: column;
		}

		.uvlistitem-user {
			.user-name {
				color: #7d90a9;
				font-weight: 700;
			}

			.user-text {
				margin: 10rpx 0 50rpx 0;
			}

			.user-time {
				font-size: 20rpx;
				color: #9f9f9f;
				margin-top: 30rpx;
			}
		}
	}

	.fixed-bottom {
		position: fixed;
		bottom: 0;
		width: 100%;
		padding: 15px;
		background-color: #fff;
		box-shadow: 0 -10rpx 10px rgba(0, 0, 0, 0.5);
	}

	.uvloadmorebox {
		height: 260rpx;
		z-index: 1000;
		// margin-top: 60rpx;
		overflow: hidden;
		// background-color: #ffaa7f;
	}
</style>